package com.starleague.game.jpa.appengine;

import java.util.Map;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;

import com.starleague.game.IGame;
import com.starleague.jpa.appengine.GaeDao;

@MappedSuperclass
public abstract class AbstractGameGae
        extends GaeDao
        implements IGame
{
    // TODO: If this is too long, feel free to validate the value in (concrete) the constructor
    private static final int MAX_NAME_LENGTH = 64;

    @Basic(optional = false)
    @Column(nullable = false, length = MAX_NAME_LENGTH)
    private String name;

    protected AbstractGameGae(String name)
    {
        this.name = name;
    }

    protected AbstractGameGae()
    {
        //
    }

    @Override
    public String getName()
    {
        return this.name;
    }

    @Override
    public Map<String, Object> infoProperties()
    {
        Map<String, Object> infoPropertyMap = super.infoProperties();
        infoPropertyMap.put("name", this.name);
        return infoPropertyMap;
    }
}
